#!/bin/bash
# author tyb
# date 20240217

# 定义NFS服务器的IP地址或主机名
NFS_SERVER="192.168.137.11"

# 检查NFS挂载状态
check_nfs_mount() {
    if mount | grep -q "$NFS_SERVER"; then
        echo -e "$(date): \e[32mNFS已挂载在$NFS_SERVER\e[0m" > /var/log/check_nfs_mount.log
    else
        echo -e "$(date): \e[31mNFS未挂载在$NFS_SERVER\e[0m" > /var/log/check_nfs_mount.log
        # 这里可以添加挂载NFS的命令
        mount -a
    fi
}

# 调用检查函数
check_nfs_mount            